﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Com.JunCaiSoft.Freeze.Model
{
    public class UnFreezeMoneyView
    {
        /// <summary>
        /// 解冻资金标识
        /// </summary>
        public virtual Guid Id { get; set; }
        /// <summary>
        /// 解冻序号
        /// </summary>
        public virtual Int64 Num { get; set; }
        /// <summary>
        /// 解冻编码
        /// </summary>
        public virtual String NumCode { get; set; }
        /// <summary>
        /// 被解冻信息
        /// </summary>
        public virtual Guid FreezeInfo { get; set; }
        /// <summary>
        /// 利率周期
        /// </summary>
        public virtual String RatePeriod { get; set; }
        /// <summary>
        /// 约定利率
        /// </summary>
        public virtual Double Rate { get; set; }
        /// <summary>
        /// 解冻金额
        /// </summary>
        public virtual Double Amount { get; set; }
        /// <summary>
        /// 冻结时间【取自冻结资金管理，必须与冻结管理解冻时间一致】
        /// </summary>
        public virtual DateTime FreezeTime { get; set; }
        /// <summary>
        /// 解冻日期
        /// </summary>
        public virtual DateTime UnFreezeTime { get; set; }
        /// <summary>
        /// 解冻天数
        /// </summary>
        public virtual Int32 FreezeDayCount
        {
            get
            {
                return ((UnFreezeTime.ToString("yyyy-MM-dd") == DateTime.MaxValue.ToString("yyyy-MM-dd") ||
                           UnFreezeTime.ToString("yyyy-MM-dd") == DateTime.MaxValue.AddDays(-1).ToString("yyyy-MM-dd") ? DateTime.Now : UnFreezeTime) - FreezeTime).Days;
            }
        }
        /// <summary>
        /// 应确认利息
        /// </summary>
        public virtual Double FreezeInterest
        {
            get
            {
                var interest = 0.0;

                switch (RatePeriod)
                {
                    case "DAY":
                        interest = Amount * (Rate / 100) * FreezeDayCount;
                        break;
                    case "MONTY":
                        interest = Amount * (Rate / 100 / 30) * FreezeDayCount;
                        break;
                    case "YEAR":
                        interest = Amount * (Rate / 100 / 360) * FreezeDayCount;
                        break;
                    default:
                        interest = Amount * (Rate / 100) * FreezeDayCount;
                        break;
                }

                return interest;
            }
        }
        /// <summary>
        /// 利率展现字段
        /// </summary>
        public virtual String FreezeRateShow
        {
            get
            {
                var ratetype = "";

                switch (RatePeriod)
                {
                    case "DAY":
                        ratetype = "日利率";
                        break;
                    case "MONTH":
                        ratetype = "月利率";
                        break;
                    case "YEAR":
                        ratetype = "年利率";
                        break;
                    default:
                        ratetype = "月利率";
                        break;
                }

                return ratetype + "  " + Rate + "%";
            }
        }
        /// <summary>
        /// 创建日期
        /// </summary>
        public virtual DateTime CreateTime { get; set; }
    }
}
